﻿package Classes.Enemies.Emplacements
{
	import flash.display.*;
	import flash.geom.*;
	
	import Classes.Weapons.*;
	import Classes.Elements.*;
	import Classes.Weapons.Bullets.*;	
	import Classes.Enemies.*;
	import Classes.Utils.*;
	import Classes.Sounds.GameSound;
	
	public class Karl extends Emplacement{
		
		public function Karl(){			
			pointable = true;
			aFirePoints = [[0,-35]];
			omega = 2.5;			
			life = 150;
			hp = 150;
			execution = 30;
			weaponType = WeaponType.KarlBullet;
			score = UnitType.Karl.score;
		}
		override public function fire():void{
			if((inc + 4) % weaponType.interval == 0){
				GameSound.KarlBulletShoot.play();
				gotoAndPlay("fire");
				pointable = false;
			}
			if(inc % weaponType.interval == 0){				
				var kb:KarlBullet = new KarlBullet();
				var gpos:Array = getGolbalFirePoints();
				kb.aTargets = this.aTargets;
				kb.rotation = this.rotation;
				kb.angle = -this.rotation;
				kb.sender = this;
				kb.x = gpos[0][0];
				kb.y = gpos[0][1];
				bulletLayer.addChild(kb);				
				pointable = true;
			}			
		}
		override protected function move():void{
			inc++;
			super.move();
			if(pointable)
				Moving.pointTo(this,aTargets[0],omega);			
			if(fireable)
				fire();
		}
	}
}